import java.util.Scanner;

public class Texts {
    public static void main(String[] args) {
        TriangleArea1();
        SquareArea1();
        RectangleArea1();

        TriangleArea2(2, 2);
        SquareArea2(2);
        RectangleArea2(2, 3);

        System.out.println(TriangleArea3(2, 2));
        System.out.println(SquareArea3(2));
        System.out.println(RectangleArea3(2, 3));
    }

    public static void TriangleArea1(){
        Scanner reader = new Scanner(System.in);
        System.out.println("请输入三角形的底：");
        double a = reader.nextInt();
        System.out.println("请输入三角形的高：");
        double b = reader.nextInt();
        System.out.println("三角形的面积为"+(a*b/2));
    }
    public static void SquareArea1(){
        Scanner reader = new Scanner(System.in);
        System.out.println("请输入正方形的边长：");
        double a = reader.nextInt();
        System.out.println("正方形的面积为"+Math.pow(a,2));
    }
    public static void RectangleArea1(){
        Scanner reader = new Scanner(System.in);
        System.out.println("请输入长方形的底：");
        double a = reader.nextInt();
        System.out.println("请输入长方形的高：");
        double b = reader.nextInt();
        System.out.println("长方形的面积为"+a*b);
    }

    public static void TriangleArea2(double a,double b){
        System.out.println("三角形的底为"+a);
        System.out.println("三角形的高为"+b);
        System.out.println("三角形的面积为"+(a*b/2));
        System.out.println(" ");
    }
    public static void SquareArea2(double a){
        System.out.println("正方形的边长为"+a);
        System.out.println("正方形的面积为"+Math.pow(a,2));
        System.out.println(" ");
    }
    public static void RectangleArea2(double a,double b){
        System.out.println("长方形的长为"+a);
        System.out.println("长方形的宽为"+b);
        System.out.println("长方形的面积为"+a*b);
        System.out.println(" ");
    }

    public static double TriangleArea3(double a,double b){
        System.out.println("三角形的底为"+a);
        System.out.println("三角形的高为"+b);
        System.out.println("三角形的面积为");
        return a*b/2;
    }
    public static double SquareArea3(double a){
        System.out.println("正方形的边长为"+a);
        System.out.println("正方形的面积为");
        return Math.pow(a,2);
    }
    public static double RectangleArea3(double a,double b){
        System.out.println("长方形的长为"+a);
        System.out.println("长方形的宽为"+b);
        System.out.println("长方形的面积为");
        return a*b;
    }
}
//定义三个无参数无返回值方法，分别实现计算三角形、正方形、长方形的面积。
//定义三个有参数无返回值方法，分别实现计算三角形、正方形、长方形的面积。
//定义三个有参数有返回值方法，分别实现计算三角形、正方形、长方形的面积。